package com.coocaa.launcher.statusplugins.bluetooth;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;

import com.coocaa.launcher.framework.launcherhost.statusbar.StatusBarPluginView;
import com.tianci.appstore.R;

/**
 * Created by lu on 15-6-15.
 */
public class StatusPluginBluetoothView extends StatusBarPluginView implements StatusPluginBluetooth.IStatusPluginBluetooth {
    private ImageView img = null;

    public StatusPluginBluetoothView(Context context, String name) {
        super(context, name);
        img = new ImageView(context);
        img.setBackgroundResource(R.drawable.sp_bluetooth);
        LayoutParams ivParams = new LayoutParams(Div(46), Div(37));
        addView(img, ivParams);
        img.setVisibility(View.GONE);
    }

    @Override
    public int getConfigGravity() {
        return Gravity.RIGHT;
    }

    @Override
    public void onBind(boolean value) {
        if (value) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    img.setVisibility(View.VISIBLE);
                }
            });
        } else {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    img.setVisibility(View.GONE);
                }
            });
        }
    }
}
